﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GroupTesting : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void _addUrlButton_Click(object sender, EventArgs e)
    {
        // get the parameter from the text box
        _urlList.Items.Add(_wsdlUrl.Text);
    }
    protected void _clearUrlList_Click(object sender, EventArgs e)
    {
        _urlList.Items.Clear();
    }
    protected void _addButton_Click(object sender, EventArgs e)
    {
        // get the parameter from the text box
        String parameter = _parameterTextbox.Text;
        _parameterList.Items.Add(parameter);
    }
    protected void _clearButton_Click(object sender, EventArgs e)
    {
        _parameterList.Items.Clear();
    }
    protected void _goButton_Click(object sender, EventArgs e)
    {
        try
        {
            GroupTestingService.GroupTestingServiceClient group_testing =
                new GroupTestingService.GroupTestingServiceClient();

            List<string> urls = new List<string>();
            foreach (ListItem url in _urlList.Items)
            {
                urls.Add(url.ToString());
            }

            String operation_name = _operation.Text;

            List<string> arguments = new List<string>();
            foreach (ListItem item in _parameterList.Items)
            {
                arguments.Add(item.ToString());
            }

            bool results = group_testing.GroupTesting(urls.ToArray(), operation_name, arguments.ToArray());

            String message = "One or more methods are not equal to another method.";
            if( results == true )
            {
                message = "The return results for the requested operation across all services was equal";
            }

            _results.Text = message;
        }
        catch (Exception ex)
        {
            String message =
                "An Exception occured in WsTesting tester. " + ex.Message;
            _results.Text = message;
        }
    }
}